<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- | ISO 8601 Week Date format</span><span>
</span><span id="line-2"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Time.Calendar.WeekDate</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Time.Calendar.OrdinalDate.html"><span class="hs-identifier">Data.Time.Calendar.OrdinalDate</span></a></span><span>
</span><span id="line-5"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Time.Calendar.Days.html"><span class="hs-identifier">Data.Time.Calendar.Days</span></a></span><span>
</span><span id="line-6"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Time.Calendar.Private.html"><span class="hs-identifier">Data.Time.Calendar.Private</span></a></span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-comment">-- | Convert to ISO 8601 Week Date format. First element of result is year, second week number (1-53), third day of week (1 for Monday to 7 for Sunday).</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Note that \&quot;Week\&quot; years are not quite the same as Gregorian years, as the first day of the year is always a Monday.</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- The first week of a year is the first week to contain at least four days in the corresponding Gregorian year.</span><span>
</span><span id="line-11"></span><span class="annot"><a href="Data.Time.Calendar.WeekDate.html#toWeekDate"><span class="hs-identifier hs-type">toWeekDate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Time.Calendar.Days.html#Day"><span class="hs-identifier hs-type">Day</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span class="hs-special">,</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">,</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-12"></span><span id="toWeekDate"><span class="annot"><span class="annottext">toWeekDate :: Day -&gt; (Integer, Int, Int)
</span><a href="Data.Time.Calendar.WeekDate.html#toWeekDate"><span class="hs-identifier hs-var hs-var">toWeekDate</span></a></span></span><span> </span><span id="local-6989586621679069119"><span class="annot"><span class="annottext">date :: Day
</span><a href="#local-6989586621679069119"><span class="hs-identifier hs-var">date</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Data.Time.Calendar.Days.html#ModifiedJulianDay"><span class="hs-identifier hs-type">ModifiedJulianDay</span></a></span><span> </span><span id="local-6989586621679069117"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069117"><span class="hs-identifier hs-var">mjd</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069116"><span class="hs-identifier hs-var">y1</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Integer -&gt; Int
forall a. Num a =&gt; Integer -&gt; a
</span><a href="../../base/src/GHC.Num.html#fromInteger"><span class="hs-identifier hs-var">fromInteger</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069115"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><span class="annottext">Integer -&gt; Int
forall a. Num a =&gt; Integer -&gt; a
</span><a href="../../base/src/GHC.Num.html#fromInteger"><span class="hs-identifier hs-var">fromInteger</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069113"><span class="hs-identifier hs-var">d_mod_7</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-13"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679069110"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069110"><span class="hs-identifier hs-var">d_div_7</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679069113"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069113"><span class="hs-identifier hs-var">d_mod_7</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069109"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; (Integer, Integer)
forall a. Integral a =&gt; a -&gt; a -&gt; (a, a)
</span><a href="../../base/src/GHC.Real.html#divMod"><span class="hs-operator hs-var">`divMod`</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">7</span></span><span>
</span><span id="line-14"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679069107"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069107"><span class="hs-identifier hs-var">y0</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679069106"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069106"><span class="hs-identifier hs-var">yd</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Day -&gt; (Integer, Int)
</span><a href="Data.Time.Calendar.OrdinalDate.html#toOrdinalDate"><span class="hs-identifier hs-var">toOrdinalDate</span></a></span><span> </span><span class="annot"><span class="annottext">Day
</span><a href="#local-6989586621679069119"><span class="hs-identifier hs-var">date</span></a></span><span>
</span><span id="line-15"></span><span>    </span><span id="local-6989586621679069109"><span class="annot"><span class="annottext">d :: Integer
</span><a href="#local-6989586621679069109"><span class="hs-identifier hs-var hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069117"><span class="hs-identifier hs-var">mjd</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">2</span></span><span>
</span><span id="line-16"></span><span>    </span><span class="annot"><a href="#local-6989586621679069102"><span class="hs-identifier hs-type">foo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span>
</span><span id="line-17"></span><span>    </span><span id="local-6989586621679069102"><span class="annot"><span class="annottext">foo :: Integer -&gt; Integer
</span><a href="#local-6989586621679069102"><span class="hs-identifier hs-var hs-var">foo</span></a></span></span><span> </span><span id="local-6989586621679069101"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069101"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer
</span><a href="#local-6989586621679069100"><span class="hs-identifier hs-var">bar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Day -&gt; Integer
</span><a href="Data.Time.Calendar.Days.html#toModifiedJulianDay"><span class="hs-identifier hs-var hs-var">toModifiedJulianDay</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Int -&gt; Day
</span><a href="Data.Time.Calendar.OrdinalDate.html#fromOrdinalDate"><span class="hs-identifier hs-var">fromOrdinalDate</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069101"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span>    </span><span id="local-6989586621679069100"><span class="annot"><span class="annottext">bar :: Integer -&gt; Integer
</span><a href="#local-6989586621679069100"><span class="hs-identifier hs-var hs-var">bar</span></a></span></span><span> </span><span id="local-6989586621679069094"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069094"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069110"><span class="hs-identifier hs-var">d_div_7</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069094"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Integral a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#div"><span class="hs-operator hs-var">`div`</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">7</span></span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679069116"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069116"><span class="hs-identifier hs-var">y1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679069115"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069115"><span class="hs-identifier hs-var">w1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer
</span><a href="#local-6989586621679069100"><span class="hs-identifier hs-var">bar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069109"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer
forall a. Integral a =&gt; a -&gt; Integer
</span><a href="../../base/src/GHC.Real.html#toInteger"><span class="hs-identifier hs-var">toInteger</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069106"><span class="hs-identifier hs-var">yd</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">4</span></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-20"></span><span>                </span><span class="hs-glyph">-</span><span class="hs-number">1</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069107"><span class="hs-identifier hs-var">y0</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer
</span><a href="#local-6989586621679069102"><span class="hs-identifier hs-var">foo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069107"><span class="hs-identifier hs-var">y0</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span>                </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">52</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer
</span><a href="#local-6989586621679069102"><span class="hs-identifier hs-var">foo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069107"><span class="hs-identifier hs-var">y0</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span>
</span><span id="line-22"></span><span>                      </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069107"><span class="hs-identifier hs-var">y0</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span>                      </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069107"><span class="hs-identifier hs-var">y0</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">52</span></span><span class="hs-special">)</span><span>
</span><span id="line-24"></span><span>                </span><span id="local-6989586621679069070"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069070"><span class="hs-identifier hs-var">w0</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069107"><span class="hs-identifier hs-var">y0</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069070"><span class="hs-identifier hs-var">w0</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-comment">-- | Convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday).</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- Invalid week and day values will be clipped to the correct range.</span><span>
</span><span id="line-28"></span><span class="annot"><a href="Data.Time.Calendar.WeekDate.html#fromWeekDate"><span class="hs-identifier hs-type">fromWeekDate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Time.Calendar.Days.html#Day"><span class="hs-identifier hs-type">Day</span></a></span><span>
</span><span id="line-29"></span><span id="fromWeekDate"><span class="annot"><span class="annottext">fromWeekDate :: Integer -&gt; Int -&gt; Int -&gt; Day
</span><a href="Data.Time.Calendar.WeekDate.html#fromWeekDate"><span class="hs-identifier hs-var hs-var">fromWeekDate</span></a></span></span><span> </span><span id="local-6989586621679069068"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069068"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span id="local-6989586621679069067"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069067"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621679069066"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069066"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Day
</span><a href="Data.Time.Calendar.Days.html#ModifiedJulianDay"><span class="hs-identifier hs-var">ModifiedJulianDay</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069065"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Integral a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#mod"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069065"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">7</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Integer
forall a. Integral a =&gt; a -&gt; Integer
</span><a href="../../base/src/GHC.Real.html#toInteger"><span class="hs-identifier hs-var">toInteger</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; Int
forall t. Ord t =&gt; t -&gt; t -&gt; t -&gt; t
</span><a href="Data.Time.Calendar.Private.html#clip"><span class="hs-identifier hs-var">clip</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679069062"><span class="hs-identifier hs-var">longYear</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">53</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">52</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069067"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">7</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; Int
forall t. Ord t =&gt; t -&gt; t -&gt; t -&gt; t
</span><a href="Data.Time.Calendar.Private.html#clip"><span class="hs-identifier hs-var">clip</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">7</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069066"><span class="hs-identifier hs-var">d</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">10</span></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-30"></span><span>        </span><span id="local-6989586621679069065"><span class="annot"><span class="annottext">k :: Integer
</span><a href="#local-6989586621679069065"><span class="hs-identifier hs-var hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Day -&gt; Integer
</span><a href="Data.Time.Calendar.Days.html#toModifiedJulianDay"><span class="hs-identifier hs-var hs-var">toModifiedJulianDay</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Int -&gt; Day
</span><a href="Data.Time.Calendar.OrdinalDate.html#fromOrdinalDate"><span class="hs-identifier hs-var">fromOrdinalDate</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069068"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span>
</span><span id="line-31"></span><span>        </span><span id="local-6989586621679069062"><span class="annot"><span class="annottext">longYear :: Bool
</span><a href="#local-6989586621679069062"><span class="hs-identifier hs-var hs-var">longYear</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Day -&gt; (Integer, Int, Int)
</span><a href="Data.Time.Calendar.WeekDate.html#toWeekDate"><span class="hs-identifier hs-var">toWeekDate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Int -&gt; Day
</span><a href="Data.Time.Calendar.OrdinalDate.html#fromOrdinalDate"><span class="hs-identifier hs-var">fromOrdinalDate</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069068"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">365</span></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-32"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">53</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-33"></span><span>            </span><span class="annot"><span class="annottext">(Integer, Int, Int)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-comment">-- | Convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday).</span><span>
</span><span id="line-36"></span><span class="hs-comment">-- Invalid week and day values will return Nothing.</span><span>
</span><span id="line-37"></span><span class="annot"><a href="Data.Time.Calendar.WeekDate.html#fromWeekDateValid"><span class="hs-identifier hs-type">fromWeekDateValid</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="Data.Time.Calendar.Days.html#Day"><span class="hs-identifier hs-type">Day</span></a></span><span>
</span><span id="line-38"></span><span id="fromWeekDateValid"><span class="annot"><span class="annottext">fromWeekDateValid :: Integer -&gt; Int -&gt; Int -&gt; Maybe Day
</span><a href="Data.Time.Calendar.WeekDate.html#fromWeekDateValid"><span class="hs-identifier hs-var hs-var">fromWeekDateValid</span></a></span></span><span> </span><span id="local-6989586621679069056"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069056"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span id="local-6989586621679069055"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069055"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621679069054"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069054"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-39"></span><span>    </span><span id="local-6989586621679069053"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069053"><span class="hs-identifier hs-var">d'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; Maybe Int
forall t. Ord t =&gt; t -&gt; t -&gt; t -&gt; Maybe t
</span><a href="Data.Time.Calendar.Private.html#clipValid"><span class="hs-identifier hs-var">clipValid</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">7</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069054"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-41"></span><span>        </span><span id="local-6989586621679069049"><span class="annot"><span class="annottext">longYear :: Bool
</span><a href="#local-6989586621679069049"><span class="hs-identifier hs-var hs-var">longYear</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Day -&gt; (Integer, Int, Int)
</span><a href="Data.Time.Calendar.WeekDate.html#toWeekDate"><span class="hs-identifier hs-var">toWeekDate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Int -&gt; Day
</span><a href="Data.Time.Calendar.OrdinalDate.html#fromOrdinalDate"><span class="hs-identifier hs-var">fromOrdinalDate</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069056"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">365</span></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-42"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">53</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-43"></span><span>            </span><span class="annot"><span class="annottext">(Integer, Int, Int)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-44"></span><span>    </span><span id="local-6989586621679069048"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069048"><span class="hs-identifier hs-var">w'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; Maybe Int
forall t. Ord t =&gt; t -&gt; t -&gt; t -&gt; Maybe t
</span><a href="Data.Time.Calendar.Private.html#clipValid"><span class="hs-identifier hs-var">clipValid</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679069049"><span class="hs-identifier hs-var">longYear</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">53</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">52</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069055"><span class="hs-identifier hs-var">w</span></a></span><span>
</span><span id="line-45"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-46"></span><span>        </span><span id="local-6989586621679069047"><span class="annot"><span class="annottext">k :: Integer
</span><a href="#local-6989586621679069047"><span class="hs-identifier hs-var hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Day -&gt; Integer
</span><a href="Data.Time.Calendar.Days.html#toModifiedJulianDay"><span class="hs-identifier hs-var hs-var">toModifiedJulianDay</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Int -&gt; Day
</span><a href="Data.Time.Calendar.OrdinalDate.html#fromOrdinalDate"><span class="hs-identifier hs-var">fromOrdinalDate</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069056"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span>
</span><span id="line-47"></span><span>    </span><span class="annot"><span class="annottext">Day -&gt; Maybe Day
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Day
</span><a href="Data.Time.Calendar.Days.html#ModifiedJulianDay"><span class="hs-identifier hs-var">ModifiedJulianDay</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069047"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Integral a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#mod"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069047"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">7</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Integer
forall a. Integral a =&gt; a -&gt; Integer
</span><a href="../../base/src/GHC.Real.html#toInteger"><span class="hs-identifier hs-var">toInteger</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069048"><span class="hs-identifier hs-var">w'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">7</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069053"><span class="hs-identifier hs-var">d'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">10</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-comment">-- | Show in ISO 8601 Week Date format as yyyy-Www-d (e.g. \&quot;2006-W46-3\&quot;).</span><span>
</span><span id="line-50"></span><span class="annot"><a href="Data.Time.Calendar.WeekDate.html#showWeekDate"><span class="hs-identifier hs-type">showWeekDate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Time.Calendar.Days.html#Day"><span class="hs-identifier hs-type">Day</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-51"></span><span id="showWeekDate"><span class="annot"><span class="annottext">showWeekDate :: Day -&gt; String
</span><a href="Data.Time.Calendar.WeekDate.html#showWeekDate"><span class="hs-identifier hs-var hs-var">showWeekDate</span></a></span></span><span> </span><span id="local-6989586621679069045"><span class="annot"><span class="annottext">Day
</span><a href="#local-6989586621679069045"><span class="hs-identifier hs-var">date</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; String
forall t. ShowPadded t =&gt; t -&gt; String
</span><a href="Data.Time.Calendar.Private.html#show4"><span class="hs-identifier hs-var">show4</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069043"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-W&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; String
forall t. ShowPadded t =&gt; t -&gt; String
</span><a href="Data.Time.Calendar.Private.html#show2"><span class="hs-identifier hs-var">show2</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069041"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069039"><span class="hs-identifier hs-var">d</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-52"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679069043"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679069043"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679069041"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069041"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679069039"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679069039"><span class="hs-identifier hs-var">d</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Day -&gt; (Integer, Int, Int)
</span><a href="Data.Time.Calendar.WeekDate.html#toWeekDate"><span class="hs-identifier hs-var">toWeekDate</span></a></span><span> </span><span class="annot"><span class="annottext">Day
</span><a href="#local-6989586621679069045"><span class="hs-identifier hs-var">date</span></a></span><span>
</span><span id="line-53"></span></pre></body></html>